1206A - Choose Two Numbers - CodeForces Solution


math sortings *800

Please click on ads to support us..

Python Code:



import bisect
import random

mod = 10 ** 9 + 7
eps = 10 ** -9

def _miillerTest(d, n):
    a = 2 + random.randint(1, n - 4)
    x = pow(a, d, n)
    if (x == 1 or x == n - 1):
        return True
    while (d != n - 1):
        x = (x * x) % n
        d *= 2;
 
        if (x == 1):
            return False
        if (x == n - 1):
            return True
    return False;

def _isprime(n):
    if (n < 2 or n == 4):
        return False
    if (n <= 3):
        return True
    d = n - 1;
    while (d % 2 == 0):
        d //= 2
    for i in range(5):
        if (_miillerTest(d, n) == False):
            return False
 
    return True

def _gcd(a, b):
    return a if b == 0 else _gcd(b, a % b)
  

def _lcm(a, b):
  return a * b / __gcd(a, b)

def _mex(a):
    mex = 0
    a.sort()
    for x in a:
        if x <= mex:
            mex += 1
        else:
            break
    return mex

def _dist(x1, y1, x2, y2):
  return (x1 - x2) ** 2 + (y1 - y2) ** 2

def _getprimes(n, m):
    primes = []
    if n <= 2:
        primes.append(2)
    if n % 2 == 0:
        n += 1
    for i in range(n, m + 1, 2):
        if _isprime(i):
            primes.append(i)
    return primes
  
def _primefactors(n):
    ret = []
    x = n
    i = 2
    if _isprime(n):
        ret.append(n)
        return ret
    while i * i <= x:
        while n % i == 0:      
            ret.append(i)
            n //= i
            if _isprime(n):
                break
        i += 1
    if n > 1:
        ret.append(n)
    return ret
  
def _pollardrho(n):
    if n % 2 == 0: return 2
    if _isprime(n): return n
    while True:
        c = random.randint(2, n -1)
        f = lambda x: x**2 + c 
        x = y = 2 
        d = 1 
        while d == 1:
            x = f(x) % n 
            y = f(f(y)) % n 
            d = _gcd((x - y) % n, n)
        
        if d != n and _isprime(d): return d

def _sumdigit(n):
  ret = 0
  while n > 0:
    ret += n % 10
    n //= 10
  return ret

def _modinverse(n, m):
    return (n % mod) * (pow(m, mod - 2, mod) % mod) % mod


def lip(type = int):
	return list(map(type, input().split()))
 
def mip(type = int):
	return map(type, input().split())
 
def tip(type = int):
	return type(input())

def solve(t):
	n = tip()
	a = lip()
	m = tip()
	b = lip()
	
	print(max(a), max(b))
	
t = 1
for i in range(t):
    solve(i + 1)


Comments

Submit
0 Comments
More Questions

22A - Second Order Statistics
1720B - Interesting Sum
1720A - Burenka Plays with Fractions
3A - Shortest path of the king
1720C - Corners
574A - Bear and Elections
352B - Jeff and Periods
1244A - Pens and Pencils
1670A - Prof Slim
1189A - Keanu Reeves
678A - Johny Likes Numbers
1699C - The Third Problem
1697D - Guess The String
754B - Ilya and tic-tac-toe game
760A - Petr and a calendar
1573A - Countdown
166A - Rank List
1631B - Fun with Even Subarrays
727A - Transformation from A to B
822B - Crossword solving
1623A - Robot Cleaner
884B - Japanese Crosswords Strike Back
862B - Mahmoud and Ehab and the bipartiteness
429A - Xor-tree
1675C - Detective Task
950A - Left-handers Right-handers and Ambidexters
672B - Different is Good
1C - Ancient Berland Circus
721A - One-dimensional Japanese Crossword
1715B - Beautiful Array